package com.lishe.lishe.lishe.module.excitation.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lishe.lishe.Imageloader.ImageLoaderUtils;
import com.lishe.lishe.R;
import com.lishe.lishe.lishe.base.BaseActivity;
import com.lishe.lishe.lishe.module.excitation.bean.user.UserObject;
import com.lishe.lishe.lishe.widget.CircleImageView;

/**
 * Created by yang on 2017/11/20.
 * 所属企业
 */

public class PersonMessageComNameActivity extends BaseActivity implements View.OnClickListener {

    public static void jump(Activity activity,UserObject userObject){
        Intent intent=new Intent(activity,PersonMessageComNameActivity.class);
        mUserObject=userObject;
        activity.startActivity(intent);
    }

    private TextView mTextComName,
            mTextShortName,
            mTextFapiao,
            mTextNaShui,
            mTextTitle;

    private CircleImageView mImageHead;
    private Button mButtonBack;
    private LinearLayout mLinearFapiao,mLinearNashui;

    private static UserObject mUserObject=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person_com_name);
        initView();
        setListener();
        if(mUserObject!=null) {
            updateView(mUserObject);
        }
    }




    private void updateView(UserObject dataResponse) {
        if(!TextUtils.isEmpty(dataResponse.getComLogoPath())){
            ImageLoaderUtils.displayImage(this, dataResponse.getComLogoPath(),mImageHead,R.mipmap.head);
        }

        mTextComName.setText(dataResponse.getComName());
        mTextShortName.setText(dataResponse.getComShortName());
        if(TextUtils.isEmpty(dataResponse.getInvoiceTitle())){
            mLinearFapiao.setVisibility(View.GONE);
        }else{
            mLinearFapiao.setVisibility(View.VISIBLE);
            mTextFapiao.setText(dataResponse.getInvoiceTitle());
        }

        if(TextUtils.isEmpty(dataResponse.getTaxperNo())){
            mLinearNashui.setVisibility(View.GONE);
        }else{
            mLinearNashui.setVisibility(View.VISIBLE);
            mTextNaShui.setText(dataResponse.getTaxperNo());
        }
    }

    private void initView() {
        mTextComName=findViewById(R.id.comName);
        mTextShortName=findViewById(R.id.shortName);
        mTextFapiao=findViewById(R.id.fapiao);
        mTextNaShui=findViewById(R.id.nashui);
        mButtonBack=findViewById(R.id.title_left_button);
        mImageHead=findViewById(R.id.head);
        mTextTitle=findViewById(R.id.title_text_title);
        mLinearFapiao=findViewById(R.id.ll_fapiao);
        mLinearNashui=findViewById(R.id.ll_nashui);

        mTextTitle.setText("所属企业");
    }

    private void setListener() {
        mButtonBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.title_left_button:
                finish();
                break;
        }
    }
}
